import inherits from "inherits";

import BpmnModeler from 'bpmn-js/lib/Modeler';

// 自定义palette、contextPad
import CustomExt from "./index";
// 翻译
import customTranslate from './Translate/customTranslate'
// 官方-创建附加
import {CreateAppendAnythingModule} from 'bpmn-js-create-append-anything';
// 流程图校验部分
import lintModule from 'bpmn-js-bpmnlint';
import {resolver, rules} from "./Lint/bpmnlint";
// 官方-颜色选择器
import BpmnColorPickerModule from 'bpmn-js-color-picker';
// 扩展属性
import flowableDescriptor from './Descriptor/flowable.json'


function CustomModeler(options) {
    // 校验规则
    options.linting = Object.assign({
        active: true,
        bpmnlint: {
            config: {
                rules: {...rules, "task-required": "error"}
            },
            resolver
        }
    }, options.linting || {});

    // 属性扩展
    options.moddleExtensions = Object.assign({
        flowableDescriptor
    }, options.moddleExtensions || {});

    BpmnModeler.call(this, options);
}

inherits(CustomModeler, BpmnModeler);

CustomModeler.prototype._modules = [].concat(BpmnModeler.prototype._modules, [
    CustomExt,
    {translate: ["value", customTranslate]},
    CreateAppendAnythingModule,
    BpmnColorPickerModule,
    lintModule
]);


export default CustomModeler;
